﻿using System;
using System.Collections.Concurrent;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.Diagnostics;
using System.Linq;
using System.Text;
using System.Threading;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;
using System.Xml;
using System.Xml.Linq;

namespace WpfApp1
{
    /// <summary>
    /// MainWindow.xaml 的交互逻辑
    /// </summary>
    public partial class MainWindow : Window
    {
        public MainWindow()
        {
            InitializeComponent();
            
        }

        private void OnClick(object sender, RoutedEventArgs e)
        {
            var selectItem = TreeView.SelectedItem;
            // 创建一个集合来存储选中节点的信息
            ObservableCollection<string> selectedNodesInfo = new ObservableCollection<string>();
            if (selectItem is XmlNode)
            {
                // 根据节点类型处理节点数据
                if (selectItem is XmlElement element)
                {
                    // 获取节点的名称和值
                    string nodeName = element.Name;
                    string nodeValue = element.InnerText;

                    // 将节点信息添加到集合中
                    selectedNodesInfo.Add($"Node Name: {nodeName}, Node Value: {nodeValue}");
                }
            }

            //// 遍历选中的节点
            //foreach (XmlNode node in selectItem)
            //{
            //    // 根据节点类型处理节点数据
            //    if (node is XmlElement element)
            //    {
            //        // 获取节点的名称和值
            //        string nodeName = element.Name;
            //        string nodeValue = element.InnerText;

            //        // 将节点信息添加到集合中
            //        selectedNodesInfo.Add($"Node Name: {nodeName}, Node Value: {nodeValue}");
            //    }
            //}

            //// 处理选中节点的信息，例如显示在MessageBox中
            //MessageBox.Show($"Selected Nodes: {string.Join(", ", selectedNodesInfo)}");
        }
    }

    public class Fun1
    {
        private static Fun1 instance=new Fun1();
        public static Fun1 Instance
        {
            get
            {
                return instance;
            }
        }
    }
}
